/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.minierp.bean.CooperBillBean;
import com.minierp.bean.PayBillBean;
import com.minierp.bean.PurchaseBillBean;
import com.minierp.bean.QueryParameterBean;
import com.minierp.bean.QueryResult;
import com.minierp.bean.UserBean;
import com.minierp.bean.UserStatus;
import com.minierp.dao.AdjustBillDao;
import com.minierp.dao.AreaDao;
import com.minierp.dao.BankAccountBalanceDao;
import com.minierp.dao.BankAccountDao;
import com.minierp.dao.BankAccountDetailDao;
import com.minierp.dao.CodeRuleDao;
import com.minierp.dao.CooperBillDao;
import com.minierp.dao.DepartmentDao;
import com.minierp.dao.FinanceDetailDao;
import com.minierp.dao.IdGenerator;
import com.minierp.dao.PayBillDao;
import com.minierp.dao.PayBillItemDao;
import com.minierp.dao.PayModeDao;
import com.minierp.dao.PurchaseBillDao;
import com.minierp.dao.QueryDao;
import com.minierp.dao.TallySetDao;
import com.minierp.err.NotAllowException;
import com.minierp.err.PermissionDennyException;
import com.minierp.helper.EncCommonHelper;
import com.minierp.helper.EncInterceptorHelper;
import com.minierp.helper.EncPayBillMACtrHelper;
import com.minierp.helper.PageHelper;
import com.minierp.model.BankAccount;
import com.minierp.model.CooperBill;
import com.minierp.model.Department;
import com.minierp.model.EnterpriseInfo;
import com.minierp.model.Establishment;
import com.minierp.model.PayBill;
import com.minierp.model.PurchaseBill;
import com.minierp.model.TallySet;
import com.minierp.service.PayBillService;
import com.minierp.view.CooPayCostListExcelView;
import com.minierp.view.PayBillListExcelView;
import com.minierp.view.PayableListExcelView;
import com.minierp.view.PurPayCostListExcelView;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.springframework.dao.CannotAcquireLockException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class PayBillMACtr extends MultiActionController {
	private String payTypeSelectView;
	private String dialogSuccessView;
	private String listForExamineView;
	private String infoForExamineView;
	private String listForUnExamineView;
	private String infoForUnExamineView;
	private String searchResultView;
	private String financeListForProviderView;
	private String financeListForCooperatorView;
	private String itemListForPurchaseBillView;
	private String listForCancelView;
	private String infoForCancelView;
	private String purPayCostListView;
	private String purPayCostPrintView;
	private String cooPayCostListView;
	private String cooPayCostPrintView;
	private String payableListView;
	private String itemListForCooperBillView;
	private String printView;
	private String payableCountView;
	private String listForEstablishmentView;
	private PurchaseBillDao purchaseBillDao;
	private CooperBillDao cooperBillDao;
	private PayBillDao payBillDao;
	private AdjustBillDao adjustBillDao;
	private PayBillItemDao payBillItemDao;
	private DepartmentDao departmentDao;
	private BankAccountDao bankAccountDao;
	private BankAccountBalanceDao bankAccountBalanceDao;
	private BankAccountDetailDao bankAccountDetailDao;
	private PayModeDao payModeDao;
	private TallySetDao tallySetDao;
	private AreaDao areaDao;
	private QueryDao queryDao;
	private FinanceDetailDao financeDetailDao;
	private CodeRuleDao codeRuleDao;
	private IdGenerator idGenerator;
	private PayBillService payBillService;
	private DataSource dataSource;

	public AreaDao getAreaDao() {
		return this.areaDao;
	}

	public void setAreaDao(AreaDao areaDao) {
		this.areaDao = areaDao;
	}

	public ModelAndView handlePayTypeSelect(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "PAY_BILL")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.payTypeSelectView);
			return mv;
		}
	}

	public ModelAndView handleExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.dialogSuccessView);
		UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
		String idStr = request.getParameter("id_str");
		String flag = request.getParameter("flag");
		boolean examined = false;
		if (flag != null && flag.equals("1")) {
			examined = true;
		}

		String[] arr = idStr.split(";");
		boolean num = false;
		String msg;
		byte arg18;
		if (!examined) {
			if (!EncCommonHelper.checkPrivilege(request, "PAY_UN_EXAM")) {
				throw new Exception("Permission deny!");
			}

			try {
				for (int examinerId = 0; examinerId < arr.length; ++examinerId) {
					this.payBillService.txUnExamine(
							Long.parseLong(arr[examinerId]), this.payBillDao,
							this.payBillItemDao, this.adjustBillDao,
							this.bankAccountBalanceDao,
							this.bankAccountDetailDao, this.financeDetailDao,
							this.idGenerator, ub);
				}

				msg = "反审核成功";
			} catch (NotAllowException arg16) {
				msg = arg16.getMessage();
			} catch (CannotAcquireLockException arg17) {
				msg = "事务冲突故障，请重新操作！";
			}

			arg18 = 1;
		} else {
			if (!EncCommonHelper.checkPrivilege(request, "PAY_EXAM")) {
				throw new Exception("Permission deny!");
			}

			long arg19 = ub.getStaffer().getId();
			String examinerName = ub.getStaffer().getStafferName();

			try {
				for (int w = 0; w < arr.length; ++w) {
					this.payBillService.txExamine(Long.parseLong(arr[w]),
							this.payBillDao, this.payBillItemDao,
							this.adjustBillDao, arg19, examinerName,
							this.bankAccountBalanceDao, this.idGenerator);
				}

				msg = "审核成功";
			} catch (NotAllowException arg14) {
				msg = arg14.getMessage();
			} catch (CannotAcquireLockException arg15) {
				msg = "事务冲突故障，请重新操作！";
			}

			arg18 = 1;
		}

		mv.addObject("returnValue", String.valueOf(arg18));
		EncCommonHelper.setAlertMessage(request, msg);
		return mv;
	}

	public ModelAndView handleListForExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "PAY_EXAM")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.listForExamineView);
			String searchKey = request.getParameter("search_key");
			String tsId = request.getParameter("ts_id");
			UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
			if (tsId == null || tsId.equals("")) {
				tsId = String.valueOf(ub.getUser().getDfTsId());
			}

			long managerId = 0L;
			if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
				managerId = ub.getStaffer().getId();
			}

			Date allowStart = null;
			if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
				allowStart = EncCommonHelper.getEarlDataDate(request);
			}

			List tsList = PageHelper.getTallySetList(this.tallySetDao, ub);
			int perPageNum = EncCommonHelper.getPageSize(request);
			List cList = this.payBillDao.getListCount(searchKey, false,
					Long.parseLong(tsId), ub, managerId, allowStart);
			int total = 0;
			BigDecimal costTotal = new BigDecimal(0);
			if (cList != null && !cList.isEmpty()) {
				Object[] pageno = (Object[]) cList.get(0);
				if (pageno != null) {
					if (pageno[0] != null) {
						total = Integer.parseInt(pageno[0].toString());
					}

					if (pageno[1] != null) {
						costTotal = new BigDecimal(pageno[1].toString());
					}
				}
			}

			int pageno1 = EncCommonHelper.getCurrentPageIndex(request, total,
					perPageNum);
			int startIndex = (pageno1 - 1) * perPageNum;
			List list = this.payBillDao.getList(searchKey, false,
					Long.parseLong(tsId), ub, managerId, allowStart,
					startIndex, perPageNum);
			mv.addObject("qr", EncCommonHelper.parseQueryResult(list, total,
					perPageNum, pageno1));
			mv.addObject("searchKey", searchKey);
			mv.addObject("costTotal", costTotal);
			mv.addObject("tsId", tsId);
			mv.addObject("tsList", tsList);
			return mv;
		}
	}

	public ModelAndView handleInfoForExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.infoForExamineView);
		String id = request.getParameter("id");
		this.getPayBill(mv, Long.parseLong(id));
		return mv;
	}

	public ModelAndView handleListForUnExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "PAY_UN_EXAM")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.listForUnExamineView);
			String searchKey = request.getParameter("search_key");
			String tsId = request.getParameter("ts_id");
			UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
			if (tsId == null || tsId.equals("")) {
				tsId = String.valueOf(ub.getUser().getDfTsId());
			}

			long managerId = 0L;
			if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
				managerId = ub.getStaffer().getId();
			}

			Date allowStart = null;
			if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
				allowStart = EncCommonHelper.getEarlDataDate(request);
			}

			List tsList = PageHelper.getTallySetList(this.tallySetDao, ub);
			int perPageNum = EncCommonHelper.getPageSize(request);
			List cList = this.payBillDao.getListCount(searchKey, true,
					Long.parseLong(tsId), ub, managerId, allowStart);
			int total = 0;
			if (cList != null && !cList.isEmpty()) {
				Object[] pageno = (Object[]) cList.get(0);
				if (pageno != null && pageno[0] != null) {
					total = Integer.parseInt(pageno[0].toString());
				}
			}

			int pageno1 = EncCommonHelper.getCurrentPageIndex(request, total,
					perPageNum);
			int startIndex = (pageno1 - 1) * perPageNum;
			List list = this.payBillDao.getList(searchKey, true,
					Long.parseLong(tsId), ub, managerId, allowStart,
					startIndex, perPageNum);
			mv.addObject("qr", EncCommonHelper.parseQueryResult(list, total,
					perPageNum, pageno1));
			mv.addObject("searchKey", searchKey);
			mv.addObject("tsId", tsId);
			mv.addObject("tsList", tsList);
			return mv;
		}
	}

	public ModelAndView handleInfoForUnExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.infoForUnExamineView);
		String id = request.getParameter("id");
		this.getPayBill(mv, Long.parseLong(id));
		return mv;
	}

	public ModelAndView handleListForCancel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "PAY_CANC")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.listForCancelView);
			String searchKey = request.getParameter("search_key");
			String tsId = request.getParameter("ts_id");
			UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
			if (tsId == null || tsId.equals("")) {
				tsId = String.valueOf(ub.getUser().getDfTsId());
			}

			long managerId = 0L;
			if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
				managerId = ub.getStaffer().getId();
			}

			Date allowStart = null;
			if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
				allowStart = EncCommonHelper.getEarlDataDate(request);
			}

			List tsList = PageHelper.getTallySetList(this.tallySetDao, ub);
			int perPageNum = EncCommonHelper.getPageSize(request);
			int total = this.payBillDao.getListCount(searchKey,
					Long.parseLong(tsId), ub, managerId, allowStart);
			int pageno = EncCommonHelper.getCurrentPageIndex(request, total,
					perPageNum);
			int startIndex = (pageno - 1) * perPageNum;
			List list = this.payBillDao.getList(searchKey,
					Long.parseLong(tsId), ub, managerId, allowStart, "",
					startIndex, perPageNum);
			mv.addObject("qr", EncCommonHelper.parseQueryResult(list, total,
					perPageNum, pageno));
			mv.addObject("searchKey", searchKey);
			mv.addObject("tsId", tsId);
			mv.addObject("tsList", tsList);
			return mv;
		}
	}

	public ModelAndView handleInfoForCancel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.infoForCancelView);
		String id = request.getParameter("id");
		this.getPayBill(mv, Long.parseLong(id));
		return mv;
	}

	public ModelAndView handleCancel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.dialogSuccessView);
		UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
		if (!EncCommonHelper.checkPrivilege(request, "PAY_CANC")) {
			throw new Exception("Permission deny!");
		} else {
			String id = request.getParameter("id");
			String reason = request.getParameter("reason");

			String msg;
			try {
				this.payBillService.txCancel(Long.parseLong(id), reason,
						this.payBillDao, this.payBillItemDao,
						this.adjustBillDao, ub, this.bankAccountBalanceDao,
						this.bankAccountDetailDao, this.financeDetailDao,
						this.idGenerator);
				msg = "作废成功！";
			} catch (NotAllowException arg8) {
				msg = arg8.getMessage();
			} catch (CannotAcquireLockException arg9) {
				msg = "事务冲突故障，请重新操作！";
			}

			mv.addObject("returnValue", id);
			EncCommonHelper.setAlertMessage(request, msg);
			return mv;
		}
	}

	private void getPayBill(ModelAndView mv, long id) throws Exception {
		PayBill payBill = (PayBill) this.payBillDao.get(PayBill.class, id);
		PayBillBean form = new PayBillBean();
		form.setPayBill(payBill);
		List itemList = this.payBillItemDao.getListByPayBill(payBill.getId());
		form.setItems(itemList);
		if (payBill != null) {
			Establishment beginIndex = (Establishment) this.payBillDao.get(
					Establishment.class, payBill.getReceiverId());
			if (beginIndex != null) {
				form.setReceiverName(beginIndex.getEstName());
			}

			if (payBill.getTallySetId() != 0L) {
				TallySet d = (TallySet) this.payBillDao.get(TallySet.class,
						payBill.getTallySetId());
				if (d != null) {
					form.setTallySetName(d.getTitle());
				}
			}
		}

		mv.addObject("record", form);
		if (payBill.getAttachFile() != null
				&& !payBill.getAttachFile().equals("")) {
			int beginIndex1 = payBill.getAttachFile().lastIndexOf("/");
			mv.addObject("attFile",
					payBill.getAttachFile().substring(beginIndex1 + 1));
		}

		mv.addObject("departmentList", this.departmentDao.getList(true));
		mv.addObject("bankAccountList", this.bankAccountDao.getList("", ""));
	}

	public ModelAndView handleSearchResult(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "PAY_BILL_SEAR")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.searchResultView);
			String contentType = request.getParameter("content_type");
			List bankAccountList = this.bankAccountDao.getList("", "");
			QueryParameterBean b = EncPayBillMACtrHelper.handleSearchResult(
					request, this.dataSource);
			String[] countObjs = new String[]{"sum(b.cost)"};
			QueryResult qr;
			if (contentType != null && contentType.equals("EXCEL")) {
				qr = this.queryDao.doQuery(b.getQParas(), b.getOParas(),
						(String[]) null, b.getShortNameMap(), b.getRetObjs(),
						countObjs);
				PayBillListExcelView arg16 = new PayBillListExcelView();
				HashMap arg18 = new HashMap();
				arg18.put("list", qr.getList());
				arg18.put("baList", bankAccountList);
				arg18.put("payTotal", qr.getExtCount()[0]);
				return new ModelAndView(arg16, arg18);
			} else {
				qr = this.queryDao.doQuery(b.getCurrentPage(), b.getPageSize(),
						b.getQParas(), b.getOParas(), (String[]) null,
						b.getShortNameMap(), b.getRetObjs(), countObjs);

				for (int ent = 0; ent < qr.getList().size(); ++ent) {
					Object[] ub = (Object[]) qr.getList().get(ent);
					PayBillBean bean = new PayBillBean();
					PayBill bill = (PayBill) ub[0];
					bean.setPayBill(bill);
					String baName = "";
					if (bill.getBankAccountId() != 0L) {
						for (int j = 0; j < bankAccountList.size(); ++j) {
							BankAccount ba = (BankAccount) bankAccountList
									.get(j);
							if (ba.getId() == bill.getBankAccountId()) {
								baName = ba.getBankName();
								if (ba.getAccountName() != null
										&& !ba.getAccountName().equals("")) {
									baName = baName + "(" + ba.getAccountName()
											+ ")";
								}
							}
						}
					}

					bean.setBankAccountName(baName);
					ub[0] = bean;
				}

				mv.addAllObjects(b.getParameters());
				mv.addObject("qr", qr);
				mv.addObject("payTotal", qr.getExtCount()[0]);
				EnterpriseInfo arg15 = EncCommonHelper
						.getEnterpriseInfo(request);
				UserBean arg17 = EncCommonHelper.getCurrentUserAccount(request);
				mv.addObject("myBaList", PageHelper.parseBaList(
						bankAccountList, arg15, arg17, 0L, 0L));
				mv.addObject("tsList",
						PageHelper.getTallySetList(this.tallySetDao, arg17));
				mv.addObject("depList", this.departmentDao.getList(true));
				return mv;
			}
		}
	}

	public ModelAndView handleFinanceListForProvider(
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ModelAndView mv = new ModelAndView(this.financeListForProviderView);
		String providerId = request.getParameter("provider_id");
		List bList = this.purchaseBillDao.getList(Long.parseLong(providerId),
				true, EncCommonHelper.getCurrentUserAccount(request));
		List rList = this.payBillDao.getList("PURCHASE",
				Long.parseLong(providerId), true,
				EncCommonHelper.getCurrentUserAccount(request));
		List aList = this.adjustBillDao.getList("PURCHASE_BILL",
				Long.parseLong(providerId), true,
				EncCommonHelper.getCurrentUserAccount(request));
		mv.addObject("purchaseBillList", bList);
		mv.addObject("payBillList", rList);
		mv.addObject("adjustBillList", aList);
		mv.addObject(
				"est",
				this.payBillDao.get(Establishment.class,
						Long.parseLong(providerId)));
		return mv;
	}

	public ModelAndView handleFinanceListForCooperator(
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ModelAndView mv = new ModelAndView(this.financeListForCooperatorView);
		String cooperatorId = request.getParameter("cooperator_id");
		List cList = this.cooperBillDao.getList(Long.parseLong(cooperatorId),
				true, EncCommonHelper.getCurrentUserAccount(request));
		List rList = this.payBillDao.getList("COOPER",
				Long.parseLong(cooperatorId), true,
				EncCommonHelper.getCurrentUserAccount(request));
		List aList = this.adjustBillDao.getList("COOPER_BILL",
				Long.parseLong(cooperatorId), true,
				EncCommonHelper.getCurrentUserAccount(request));
		mv.addObject("cooperBillList", cList);
		mv.addObject("payBillList", rList);
		mv.addObject("adjustBillList", aList);
		mv.addObject(
				"est",
				this.payBillDao.get(Establishment.class,
						Long.parseLong(cooperatorId)));
		return mv;
	}

	public ModelAndView handleItemListForPurchaseBill(
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		ModelAndView mv = new ModelAndView(this.itemListForPurchaseBillView);
		String id = request.getParameter("id");
		PurchaseBill purchaseBill = (PurchaseBill) this.payBillDao.get(
				PurchaseBill.class, Long.parseLong(id));
		mv.addObject("purchaseBill", purchaseBill);
		List items = this.payBillItemDao
				.getList(Long.parseLong(id), "PURCHASE");
		mv.addObject("items", items);
		return mv;
	}

	public ModelAndView handlePurPayCostList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "PURC_PAY_SEAR")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			String contentType = request.getParameter("content_type");
			List depList = this.departmentDao.getList(true);
			BigDecimal total = new BigDecimal(0);
			BigDecimal imprestTotal = new BigDecimal(0);
			BigDecimal payTotal = new BigDecimal(0);
			QueryParameterBean b = EncPayBillMACtrHelper
					.handlePayBillListForPayCost(request, "PURCHASE",
							this.dataSource);
			List recList = this.queryDao.doQuery(b.getQParas(), b.getOParas(),
					(String[]) null, b.getShortNameMap(), b.getRetObjs(),
					(String[]) null).getList();

			for (int impList = 0; impList < recList.size(); ++impList) {
				Object[] bankAccountList = (Object[]) recList.get(impList);
				PayBill mv = (PayBill) bankAccountList[0];
				PayBillBean ent = new PayBillBean();
				ent.setPayBill(mv);
				total = total.add(mv.getCost());
				payTotal = payTotal.add(mv.getCost());

				for (int ub = 0; ub < depList.size(); ++ub) {
					Department dep = (Department) depList.get(ub);
					if (dep.getId() == mv.getDepartmentId()) {
						ent.setDepartmentName(dep.getDepartmentName());
						break;
					}
				}

				bankAccountList[0] = ent;
			}

			b = EncPayBillMACtrHelper.handlePurchaseBillListForPayCost(request,
					this.dataSource);
			List arg15 = this.queryDao.doQuery(b.getQParas(), b.getOParas(),
					(String[]) null, b.getShortNameMap(), b.getRetObjs(),
					(String[]) null).getList();

			for (int arg16 = 0; arg16 < arg15.size(); ++arg16) {
				Object[] arg18 = (Object[]) arg15.get(arg16);
				PurchaseBill arg20 = (PurchaseBill) arg18[0];
				PurchaseBillBean arg24 = new PurchaseBillBean();
				arg24.setPurchaseBill(arg20);
				if (arg20.getBillType().equals("BACK")) {
					total = total.subtract(arg20.getImprest());
					imprestTotal = imprestTotal.subtract(arg20.getImprest());
				} else {
					total = total.add(arg20.getImprest());
					imprestTotal = imprestTotal.add(arg20.getImprest());
				}

				arg18[0] = arg24;
			}

			List arg17 = this.bankAccountDao.getList("", "");
			if (contentType != null && contentType.equals("EXCEL")) {
				HashMap arg21 = new HashMap();
				arg21.put("payList", recList);
				arg21.put("imprestList", arg15);
				arg21.put("total", total);
				arg21.put("bankAccountList", arg17);
				PurPayCostListExcelView arg23 = new PurPayCostListExcelView();
				return new ModelAndView(arg23, arg21);
			} else {
				ModelAndView arg19;
				if (contentType != null && contentType.equals("PRINT")) {
					arg19 = new ModelAndView(this.purPayCostPrintView);
				} else {
					arg19 = new ModelAndView(this.purPayCostListView);
				}

				arg19.addObject("payList", recList);
				arg19.addObject("imprestList", arg15);
				arg19.addAllObjects(b.getParameters());
				arg19.addObject("total", total);
				arg19.addObject("imprestTotal", imprestTotal);
				arg19.addObject("payTotal", payTotal);
				EnterpriseInfo arg22 = EncCommonHelper
						.getEnterpriseInfo(request);
				UserBean arg25 = EncCommonHelper.getCurrentUserAccount(request);
				arg19.addObject("myBaList",
						PageHelper.parseBaList(arg17, arg22, arg25, 0L, 0L));
				arg19.addObject("tsList",
						PageHelper.getTallySetList(this.tallySetDao, arg25));
				arg19.addObject("bankAccountList", arg17);
				return arg19;
			}
		}
	}

	public ModelAndView handleCooPayCostList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "COOP_PAY_SEAR")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			String contentType = request.getParameter("content_type");
			List depList = this.departmentDao.getList(true);
			BigDecimal total = new BigDecimal(0);
			BigDecimal imprestTotal = new BigDecimal(0);
			BigDecimal payTotal = new BigDecimal(0);
			QueryParameterBean b = EncPayBillMACtrHelper
					.handlePayBillListForPayCost(request, "COOPER",
							this.dataSource);
			List recList = this.queryDao.doQuery(b.getQParas(), b.getOParas(),
					(String[]) null, b.getShortNameMap(), b.getRetObjs(),
					(String[]) null).getList();

			for (int impList = 0; impList < recList.size(); ++impList) {
				Object[] bankAccountList = (Object[]) recList.get(impList);
				PayBill mv = (PayBill) bankAccountList[0];
				PayBillBean ent = new PayBillBean();
				ent.setPayBill(mv);
				total = total.add(mv.getCost());
				payTotal = payTotal.add(mv.getCost());

				for (int ub = 0; ub < depList.size(); ++ub) {
					Department dep = (Department) depList.get(ub);
					if (dep.getId() == mv.getDepartmentId()) {
						ent.setDepartmentName(dep.getDepartmentName());
						break;
					}
				}

				bankAccountList[0] = ent;
			}

			b = EncPayBillMACtrHelper.handleCooperBillListForPayCost(request,
					this.dataSource);
			List arg15 = this.queryDao.doQuery(b.getQParas(), b.getOParas(),
					(String[]) null, b.getShortNameMap(), b.getRetObjs(),
					(String[]) null).getList();

			for (int arg16 = 0; arg16 < arg15.size(); ++arg16) {
				Object[] arg18 = (Object[]) arg15.get(arg16);
				CooperBill arg20 = (CooperBill) arg18[0];
				CooperBillBean arg24 = new CooperBillBean();
				arg24.setCooperBill(arg20);
				total = total.add(arg20.getImprest());
				imprestTotal = imprestTotal.add(arg20.getImprest());
				arg18[0] = arg24;
			}

			List arg17 = this.bankAccountDao.getList("", "");
			if (contentType != null && contentType.equals("EXCEL")) {
				HashMap arg21 = new HashMap();
				arg21.put("payList", recList);
				arg21.put("imprestList", arg15);
				arg21.put("total", total);
				arg21.put("bankAccountList", arg17);
				CooPayCostListExcelView arg23 = new CooPayCostListExcelView();
				return new ModelAndView(arg23, arg21);
			} else {
				ModelAndView arg19;
				if (contentType != null && contentType.equals("PRINT")) {
					arg19 = new ModelAndView(this.cooPayCostPrintView);
				} else {
					arg19 = new ModelAndView(this.cooPayCostListView);
				}

				arg19.addObject("payList", recList);
				arg19.addObject("imprestList", arg15);
				arg19.addAllObjects(b.getParameters());
				arg19.addObject("total", total);
				arg19.addObject("imprestTotal", imprestTotal);
				arg19.addObject("payTotal", payTotal);
				EnterpriseInfo arg22 = EncCommonHelper
						.getEnterpriseInfo(request);
				UserBean arg25 = EncCommonHelper.getCurrentUserAccount(request);
				arg19.addObject("myBaList",
						PageHelper.parseBaList(arg17, arg22, arg25, 0L, 0L));
				arg19.addObject("tsList",
						PageHelper.getTallySetList(this.tallySetDao, arg25));
				arg19.addObject("bankAccountList", arg17);
				return arg19;
			}
		}
	}

	public ModelAndView handlePayableList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "UN_PAY_SEAR")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.payableListView);
			String searchType = request.getParameter("search_type");
			String contentType = request.getParameter("content_type");
			UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
			String searchKey = "";
			String endDateStr = "";
			String tsId = "0";
			String type = "";
			String cost = "NOT_ZERO";
			Date endDate = null;
			long managerId = 0L;
			if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
				managerId = ub.getStaffer().getId();
			}

			Date allowStart = null;
			if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
				allowStart = EncCommonHelper.getEarlDataDate(request);
			}

			mv.addObject("searchKey", request.getParameter("search_key"));
			mv.addObject("type", request.getParameter("type"));
			mv.addObject("endDate", request.getParameter("end_date"));
			mv.addObject("cost", request.getParameter("cost"));
			mv.addObject("tsId", request.getParameter("ts_id"));
			if (searchType != null && !searchType.equals("")) {
				if (searchType.equals("2")) {
					searchKey = request.getParameter("search_key");
				} else {
					String cList1 = request.getParameter("cb_sk");
					String total1 = request.getParameter("cb_type");
					String remCost = request.getParameter("cb_bill_date");
					String perPageNum = request.getParameter("cb_cost");
					String pageno = request.getParameter("cb_ts");
					if (cList1 != null && cList1.equals("1")) {
						searchKey = request.getParameter("search_key");
						mv.addObject("cbSK", cList1);
					}

					if (total1 != null && total1.equals("1")) {
						type = request.getParameter("type");
						mv.addObject("cbType", total1);
					}

					if (remCost != null && remCost.equals("1")) {
						endDateStr = request.getParameter("end_date");
						SimpleDateFormat startIndex = new SimpleDateFormat(
								"yyyy-MM-dd");
						endDate = startIndex.parse(EncCommonHelper
								.getNextDateStr(endDateStr, "yyyy-MM-dd"));
						mv.addObject("cbBillDate", remCost);
					}

					if (perPageNum != null && perPageNum.equals("1")) {
						cost = request.getParameter("cost");
						mv.addObject("cbCost", perPageNum);
					}

					if (pageno != null && pageno.equals("1")) {
						tsId = request.getParameter("ts_id");
						mv.addObject("cbTs", pageno);
					}
				}
			} else {
				searchType = "1";
				SimpleDateFormat cList = new SimpleDateFormat("yyyy-MM-dd");
				Date total = new Date();
				mv.addObject("endDate", cList.format(total));
				tsId = String.valueOf(ub.getUser().getDfTsId());
				mv.addObject("tsId", tsId);
				mv.addObject("cbTs", "1");
			}

			mv.addObject("searchType", searchType);
			List cList2 = this.payBillDao.getPayableListCount(searchKey, type,
					endDate, Long.parseLong(tsId), ub, managerId, allowStart,
					cost);
			int total2 = 0;
			BigDecimal remCost1 = new BigDecimal(0);
			if (cList2.size() > 0 && cList2.get(0) != null) {
				Object[] perPageNum1 = (Object[]) cList2.get(0);
				if (perPageNum1[0] != null) {
					total2 = Integer.parseInt(perPageNum1[0].toString());
				}

				if (perPageNum1[4] != null) {
					remCost1 = new BigDecimal(perPageNum1[4].toString());
				}
			}

			if (contentType != null && contentType.equals("EXCEL")) {
				HashMap perPageNum3 = new HashMap();
				List pageno2 = this.payBillDao.getPayableList(searchKey, type,
						endDate, Long.parseLong(tsId), ub, managerId,
						allowStart, cost, 0, total2);
				perPageNum3.put("list", pageno2);
				perPageNum3.put("remCost", remCost1);
				PayableListExcelView startIndex2 = new PayableListExcelView();
				return new ModelAndView(startIndex2, perPageNum3);
			} else {
				int perPageNum2 = EncCommonHelper.getPageSize(request);
				int pageno1 = EncCommonHelper.getCurrentPageIndex(request,
						total2, perPageNum2);
				int startIndex1 = (pageno1 - 1) * perPageNum2;
				List list = this.payBillDao.getPayableList(searchKey, type,
						endDate, Long.parseLong(tsId), ub, managerId,
						allowStart, cost, startIndex1, perPageNum2);
				mv.addObject("qr", EncCommonHelper.parseQueryResult(list,
						total2, perPageNum2, pageno1));
				mv.addObject("remCost", remCost1);
				mv.addObject("tsList",
						PageHelper.getTallySetList(this.tallySetDao, ub));
				mv.addObject("printId", request.getParameter("print_id"));
				mv.addObject("printBill", request.getParameter("print_bill"));
				mv.addObject("printDetail",
						request.getParameter("print_detail"));
				return mv;
			}
		}
	}

	public ModelAndView handleItemListForCooperBill(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.itemListForCooperBillView);
		String id = request.getParameter("id");
		CooperBill cooperBill = (CooperBill) this.payBillDao.get(
				CooperBill.class, Long.parseLong(id));
		mv.addObject("cooperBill", cooperBill);
		List items = this.payBillItemDao.getList(Long.parseLong(id), "COOPER");
		mv.addObject("items", items);
		return mv;
	}

	public ModelAndView handlePrint(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.printView);
		String id = request.getParameter("id");
		this.getPayBill(mv, Long.parseLong(id));
		mv.addObject("codeRule", this.codeRuleDao.get("PAY_BILL"));
		mv.addObject("printDetail", request.getParameter("print_detail"));
		mv.addObject("retVal", request.getParameter("ret_val"));
		return mv;
	}

	public ModelAndView handlePayableCount(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "UN_PAY_COUN")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.payableCountView);
			String year = request.getParameter("year");
			String tsId = request.getParameter("ts_id");
			Date now = new Date();
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			SimpleDateFormat yearSf = new SimpleDateFormat("yyyy");
			String currentYear = yearSf.format(now);
			if (year == null || year.equals("")) {
				year = currentYear;
			}

			Date startDate = sf.parse(year + "-01-01");
			Calendar c = Calendar.getInstance();
			c.setTime(startDate);
			c.add(1, 1);
			Date endDate = c.getTime();
			UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
			if (tsId == null || tsId.equals("")) {
				tsId = String.valueOf(ub.getUser().getDfTsId());
			}

			long managerId = 0L;
			if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
				managerId = ub.getStaffer().getId();
			}

			Date allowStart = null;
			if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
				allowStart = EncCommonHelper.getEarlDataDate(request);
			}

			List cooList = this.cooperBillDao.getMonthCost(startDate, endDate,
					Long.parseLong(tsId), ub, managerId, allowStart);
			List purList = this.purchaseBillDao.getMonthCost(startDate,
					endDate, Long.parseLong(tsId), ub, managerId, allowStart);
			ArrayList arr = new ArrayList();
			Object[] totalObjs = new Object[]{"0", "0", "0", "0", "0", "0",
					"0", "0", "0"};

			for (int i = 1; i <= 12; ++i) {
				Object[] objs = new Object[]{"0", "0", "0", "0", "0", "0", "0",
						"0", "0"};

				BigDecimal cost;
				BigDecimal adjCost;
				BigDecimal payCost;
				BigDecimal remainCost;
				Object[] tmpObjs;
				int j;
				for (j = 0; j < cooList.size(); ++j) {
					tmpObjs = (Object[]) cooList.get(j);
					if (i == Integer.parseInt(tmpObjs[0].toString())) {
						cost = new BigDecimal(tmpObjs[1].toString());
						adjCost = new BigDecimal(tmpObjs[2].toString());
						payCost = new BigDecimal(tmpObjs[3].toString());
						remainCost = cost.add(adjCost).subtract(payCost);
						objs[1] = tmpObjs[1];
						objs[3] = tmpObjs[2];
						objs[5] = tmpObjs[3];
						objs[7] = remainCost;
						objs[8] = (new BigDecimal(objs[8].toString())).add(
								remainCost).toString();
						totalObjs[1] = (new BigDecimal(totalObjs[1].toString()))
								.add(cost).toString();
						totalObjs[3] = (new BigDecimal(totalObjs[3].toString()))
								.add(adjCost).toString();
						totalObjs[5] = (new BigDecimal(totalObjs[5].toString()))
								.add(payCost).toString();
						totalObjs[7] = (new BigDecimal(totalObjs[7].toString()))
								.add(remainCost).toString();
						totalObjs[8] = (new BigDecimal(totalObjs[8].toString()))
								.add(remainCost).toString();
						break;
					}
				}

				for (j = 0; j < purList.size(); ++j) {
					tmpObjs = (Object[]) purList.get(j);
					String billType = tmpObjs[0].toString();
					if (i == Integer.parseInt(tmpObjs[1].toString())) {
						cost = new BigDecimal(tmpObjs[2].toString());
						adjCost = new BigDecimal(tmpObjs[3].toString());
						payCost = new BigDecimal(tmpObjs[4].toString());
						remainCost = cost.add(adjCost).subtract(payCost);
						if (billType.equals("BACK")) {
							cost = (new BigDecimal(0)).subtract(cost);
							adjCost = (new BigDecimal(0)).subtract(adjCost);
							payCost = (new BigDecimal(0)).subtract(payCost);
							remainCost = (new BigDecimal(0))
									.subtract(remainCost);
						}

						objs[0] = (new BigDecimal(objs[0].toString()))
								.add(cost).toString();
						objs[2] = (new BigDecimal(objs[2].toString())).add(
								adjCost).toString();
						objs[4] = (new BigDecimal(objs[4].toString())).add(
								payCost).toString();
						objs[6] = (new BigDecimal(objs[6].toString())).add(
								remainCost).toString();
						objs[8] = (new BigDecimal(objs[8].toString())).add(
								remainCost).toString();
						totalObjs[0] = (new BigDecimal(totalObjs[0].toString()))
								.add(cost).toString();
						totalObjs[2] = (new BigDecimal(totalObjs[2].toString()))
								.add(adjCost).toString();
						totalObjs[4] = (new BigDecimal(totalObjs[4].toString()))
								.add(payCost).toString();
						totalObjs[6] = (new BigDecimal(totalObjs[6].toString()))
								.add(remainCost).toString();
						totalObjs[8] = (new BigDecimal(totalObjs[8].toString()))
								.add(remainCost).toString();
					}
				}

				arr.add(objs);
			}

			mv.addObject("list", arr);
			mv.addObject("totalList", totalObjs);
			mv.addObject("year", year);
			mv.addObject("tsId", tsId);
			mv.addObject("currentYear", currentYear);
			mv.addObject("tsList",
					PageHelper.getTallySetList(this.tallySetDao, ub));
			return mv;
		}
	}

	public ModelAndView handleListForEstablishment(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.listForEstablishmentView);
		QueryParameterBean b = EncPayBillMACtrHelper
				.handleListForEstablishment(request, this.dataSource);
		String[] countObjs = new String[]{"sum(b.cost)"};
		QueryResult qr = this.queryDao.doQuery(b.getCurrentPage(),
				b.getPageSize(), b.getQParas(), b.getOParas(), (String[]) null,
				b.getShortNameMap(), b.getRetObjs(), countObjs);
		mv.addObject("qr", qr);
		mv.addObject("costTotal", qr.getExtCount()[0]);
		String id = request.getParameter("id");
		mv.addObject("id", id);
		mv.addObject("est",
				this.payBillDao.get(Establishment.class, Long.parseLong(id)));
		return mv;
	}

	public ModelAndView handleAppInfo(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HashMap map = new HashMap();

		try {
			long mapper = Long.parseLong(request.getParameter("id"));
			PayBill out = (PayBill) this.payBillDao.get(PayBill.class, mapper);
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			SimpleDateFormat sfl = new SimpleDateFormat("yyyy-MM-dd HH:mm");
			String bankName = "";
			String depName = "";
			String estName = "";
			String tsName = "";
			String creaTime = "";
			if (out.getBankAccountId() != 0L) {
				BankAccount est = (BankAccount) this.payBillDao.get(
						BankAccount.class, out.getBankAccountId());
				if (est != null) {
					bankName = est.getBankName();
					if (est.getAccountName() != null
							&& !est.getAccountName().equals("")) {
						bankName = bankName + "(" + est.getAccountName() + ")";
					}
				}
			}

			if (out.getDepartmentId() != 0L) {
				Department est1 = (Department) this.payBillDao.get(
						Department.class, out.getDepartmentId());
				if (est1 != null) {
					depName = est1.getDepartmentName();
				}
			}

			Establishment est2 = (Establishment) this.payBillDao.get(
					Establishment.class, out.getReceiverId());
			if (est2 != null) {
				estName = est2.getEstName();
			}

			TallySet ts = (TallySet) this.payBillDao.get(TallySet.class,
					out.getTallySetId());
			if (ts != null) {
				tsName = ts.getTitle();
			}

			if (out.getCreateTime() != null) {
				creaTime = sfl.format(out.getCreateTime());
			}

			map.put("estName", estName);
			map.put("code", out.getBillCode());
			map.put("date", sf.format(out.getPayDate()));
			map.put("desc", PageHelper.parseNull(out.getDescription()));
			map.put("cost", out.getCost());
			map.put("ba", bankName);
			map.put("mngName", out.getManagerName());
			map.put("depName", depName);
			map.put("mark", PageHelper.parseNull(out.getMark()));
			map.put("creaName", out.getCreaterName());
			map.put("creaTime", creaTime);
			String examName = "";
			String examTime = "";
			if (out.getExamined().equals("Y")) {
				examName = out.getExaminerName();
				if (out.getExamineTime() != null) {
					examTime = sfl.format(out.getExamineTime());
				}
			}

			map.put("exam", out.getExamined());
			map.put("examName", examName);
			map.put("examTime", examTime);
			map.put("tsName", tsName);
			map.put("status", "OK");
			map.put("errMsg", "");
		} catch (Exception arg17) {
			map.put("status", "ERROR");
			map.put("errMsg", arg17.toString());
		}

		response.setContentType("text/plain");
		response.setCharacterEncoding("utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		ObjectMapper mapper1 = new ObjectMapper();
		String json = mapper1.writeValueAsString(map);
		ServletOutputStream out1 = response.getOutputStream();
		out1.write(json.getBytes("utf-8"));
		out1.flush();
		out1.close();
		return null;
	}

	public ModelAndView handleAppList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HashMap map = new HashMap();
		UserStatus s = EncInterceptorHelper.checkAppUserSignon(request);
		UserBean ub = s.getUserBean();
		String json;
		if (ub == null) {
			map.put("status", "NO_LOGIN");
			map.put("errMsg", "");
		} else if (!EncCommonHelper.checkPrivilege(request, "PAY_BILL_SEAR")) {
			map.put("status", "ERROR");
			map.put("errMsg", "您还没有此功能的使用权限，请确认返回！");
		} else {
			try {
				String mapper = request.getParameter("est_name");
				json = request.getParameter("start_date");
				String out = request.getParameter("end_date");
				String baIdStr = request.getParameter("ba_id");
				String tsIdStr = request.getParameter("ts_id");
				String orde = request.getParameter("orde");
				String showPrev = request.getParameter("show_prev");
				String initQuer = request.getParameter("init_quer");
				long baId = 0L;
				long tsId = 0L;
				long mngId = 0L;
				if (baIdStr != null && !baIdStr.equals("")) {
					baId = Long.parseLong(baIdStr);
				}

				if (tsIdStr != null && !tsIdStr.equals("")) {
					tsId = Long.parseLong(tsIdStr);
				}

				if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
					mngId = ub.getStaffer().getId();
				}

				Date allowStart = null;
				Date startDate = null;
				Date endDate = null;
				if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
					allowStart = EncCommonHelper.getEarlDataDate(request);
				}

				SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
				SimpleDateFormat sfl = new SimpleDateFormat("yyyy-MM-dd HH:mm");
				if (json != null && !json.equals("")) {
					startDate = sf.parse(json);
				}

				if (out != null && !out.equals("")) {
					endDate = sf.parse(EncCommonHelper.getNextDateStr(out,
							"yyyy-MM-dd"));
				}

				if (startDate == null) {
					startDate = allowStart;
				} else if (allowStart != null && allowStart.after(startDate)) {
					startDate = allowStart;
				}

				if (orde == null || orde.equals("")) {
					orde = "RECE_DATE";
				}

				int total = 0;
				BigDecimal cost = new BigDecimal(0);
				List list = this.payBillDao.getAppListCount(startDate, endDate,
						mapper, baId, tsId, ub, mngId);
				if (list != null && !list.isEmpty() && list.get(0) != null) {
					Object[] perPageNum = (Object[]) list.get(0);
					if (perPageNum[1] != null) {
						total = Integer.parseInt(perPageNum[0].toString());
						cost = (BigDecimal) perPageNum[1];
					}
				}

				map.put("cost", cost);
				map.put("total", Integer.valueOf(total));
				int arg43 = EncCommonHelper.getPageSize(request);
				int pageno = EncCommonHelper.getCurrentPageIndex(request,
						total, arg43);
				if (total > pageno * arg43) {
					map.put("more", "Y");
				} else {
					map.put("more", "N");
				}

				if (showPrev != null && showPrev.equals("Y")) {
					list = this.payBillDao.getAppList(startDate, endDate,
							mapper, baId, tsId, ub, mngId, orde, 0, pageno
									* arg43);
				} else {
					list = this.payBillDao.getAppList(startDate, endDate,
							mapper, baId, tsId, ub, mngId, orde, (pageno - 1)
									* arg43, arg43);
				}

				List baList = this.bankAccountDao.getList("", "");
				ArrayList items = new ArrayList();

				String ts;
				for (int ent = 0; ent < list.size(); ++ent) {
					HashMap tmpList = new HashMap();
					Object[] baItems = (Object[]) list.get(ent);
					PayBill tsItems = (PayBill) baItems[0];
					String i = (String) baItems[1];
					String item = "";
					ts = "";
					if (tsItems.getCreateTime() != null) {
						item = sfl.format(tsItems.getCreateTime());
					}

					if (tsItems.getBankAccountId() != 0L) {
						for (int j = 0; j < baList.size(); ++j) {
							BankAccount ba = (BankAccount) baList.get(j);
							if (ba.getId() == tsItems.getBankAccountId()) {
								ts = ba.getBankName();
								if (ba.getAccountName() != null
										&& !ba.getAccountName().equals("")) {
									ts = ts + "(" + ba.getAccountName() + ")";
								}
								break;
							}
						}
					}

					tmpList.put("id", Long.valueOf(tsItems.getId()));
					tmpList.put("estName", i);
					tmpList.put("cost", tsItems.getCost());
					tmpList.put("date", sf.format(tsItems.getPayDate()));
					tmpList.put("baName", ts);
					tmpList.put("creaName", tsItems.getCreaterName());
					tmpList.put("creaTime", item);
					tmpList.put("desc",
							PageHelper.parseNull(tsItems.getDescription()));
					if (tsItems.getExamined().equals("Y")) {
						tmpList.put("stat", "EXAM");
					} else {
						tmpList.put("stat", "UNEXAM");
					}

					items.add(tmpList);
				}

				map.put("items", items);
				if (initQuer != null && initQuer.equals("Y")) {
					EnterpriseInfo arg44 = EncCommonHelper
							.getEnterpriseInfo(request);
					List arg45 = PageHelper.parseBaList(baList, arg44, ub, 0L,
							0L);
					ArrayList arg46 = new ArrayList();

					for (int arg47 = 0; arg47 < arg45.size(); ++arg47) {
						HashMap arg49 = new HashMap();
						BankAccount arg51 = (BankAccount) arg45.get(arg47);
						ts = arg51.getBankName();
						if (arg51.getAccountName() != null
								&& !arg51.getAccountName().equals("")) {
							ts = ts + "(" + arg51.getAccountName() + ")";
						}

						arg49.put("id", Long.valueOf(arg51.getId()));
						arg49.put("name", ts);
						arg46.add(arg49);
					}

					arg45 = PageHelper.getTallySetList(this.tallySetDao, ub);
					ArrayList arg48 = new ArrayList();

					for (int arg50 = 0; arg50 < arg45.size(); ++arg50) {
						HashMap arg52 = new HashMap();
						TallySet arg53 = (TallySet) arg45.get(arg50);
						arg52.put("id", Long.valueOf(arg53.getId()));
						arg52.put("name", arg53.getTitle());
						arg48.add(arg52);
					}

					map.put("baItems", arg46);
					map.put("tsItems", arg48);
				}

				map.put("status", "OK");
				map.put("errMsg", "");
			} catch (Exception arg40) {
				map.put("status", "ERROR");
				map.put("errMsg", arg40.toString());
			}
		}

		response.setContentType("text/plain");
		response.setCharacterEncoding("utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		ObjectMapper arg41 = new ObjectMapper();
		json = arg41.writeValueAsString(map);
		ServletOutputStream arg42 = response.getOutputStream();
		arg42.write(json.getBytes("utf-8"));
		arg42.flush();
		arg42.close();
		return null;
	}

	public ModelAndView handleAppListForExam(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HashMap map = new HashMap();
		UserStatus s = EncInterceptorHelper.checkAppUserSignon(request);
		UserBean ub = s.getUserBean();
		String json;
		if (ub == null) {
			map.put("status", "NO_LOGIN");
			map.put("errMsg", "");
		} else if (!EncCommonHelper.checkPrivilege(request, "PAY_EXAM")) {
			map.put("status", "ERROR");
			map.put("errMsg", "您还没有此功能的使用权限，请确认返回！");
		} else {
			try {
				String mapper = request.getParameter("sk");
				json = request.getParameter("ts_id");
				String out = request.getParameter("show_prev");
				String initQuer = request.getParameter("init_quer");
				long mngId = 0L;
				long tsId = 0L;
				if (json != null && !json.equals("")) {
					tsId = Long.parseLong(json);
				}

				if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
					mngId = ub.getStaffer().getId();
				}

				Date allowStart = null;
				if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
					allowStart = EncCommonHelper.getEarlDataDate(request);
				}

				int total = 0;
				BigDecimal cost = new BigDecimal(0);
				List list = this.payBillDao.getAppListForExamCount(mapper,
						tsId, ub, allowStart, mngId);
				if (list.size() > 0 && list.get(0) != null) {
					Object[] perPageNum = (Object[]) list.get(0);
					if (perPageNum[1] != null) {
						total = Integer.parseInt(perPageNum[0].toString());
						cost = cost.add((BigDecimal) perPageNum[1]);
					}
				}

				int arg34 = EncCommonHelper.getPageSize(request);
				int pageno = EncCommonHelper.getCurrentPageIndex(request,
						total, arg34);
				if (total > pageno * arg34) {
					map.put("more", "Y");
				} else {
					map.put("more", "N");
				}

				map.put("cost", cost);
				map.put("total", Integer.valueOf(total));
				if (out != null && out.equals("Y")) {
					list = this.payBillDao.getAppListForExam(mapper, tsId, ub,
							allowStart, mngId, 0, pageno * arg34);
				} else {
					list = this.payBillDao.getAppListForExam(mapper, tsId, ub,
							allowStart, mngId, (pageno - 1) * arg34, arg34);
				}

				SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
				SimpleDateFormat sfl = new SimpleDateFormat("yyyy-MM-dd HH:mm");
				List baList = this.bankAccountDao.getList("", "");
				ArrayList items = new ArrayList();

				for (int tmpList = 0; tmpList < list.size(); ++tmpList) {
					Object[] tsItems = (Object[]) list.get(tmpList);
					PayBill i = (PayBill) tsItems[0];
					String item = (String) tsItems[1];
					String ts = "";
					String baName = "";
					if (i.getCreateTime() != null) {
						ts = sfl.format(i.getCreateTime());
					}

					if (i.getBankAccountId() != 0L) {
						for (int item1 = 0; item1 < baList.size(); ++item1) {
							BankAccount ba = (BankAccount) baList.get(item1);
							if (ba.getId() == i.getBankAccountId()) {
								baName = ba.getBankName();
								if (ba.getAccountName() != null
										&& !ba.getAccountName().equals("")) {
									baName = baName + "(" + ba.getAccountName()
											+ ")";
								}
								break;
							}
						}
					}

					HashMap arg40 = new HashMap();
					arg40.put("cost", i.getCost());
					arg40.put("creaName", i.getCreaterName());
					arg40.put("creaTime", ts);
					arg40.put("estName", item);
					arg40.put("id", Long.valueOf(i.getId()));
					arg40.put("date", sf.format(i.getPayDate()));
					arg40.put("baName", baName);
					items.add(arg40);
				}

				map.put("items", items);
				if (initQuer != null && initQuer.equals("Y")) {
					List arg35 = PageHelper.getTallySetList(this.tallySetDao,
							ub);
					ArrayList arg36 = new ArrayList();

					for (int arg37 = 0; arg37 < arg35.size(); ++arg37) {
						HashMap arg38 = new HashMap();
						TallySet arg39 = (TallySet) arg35.get(arg37);
						arg38.put("id", Long.valueOf(arg39.getId()));
						arg38.put("name", arg39.getTitle());
						arg36.add(arg38);
					}

					map.put("tsItems", arg36);
				}

				map.put("status", "OK");
				map.put("errMsg", "");
			} catch (Exception arg31) {
				map.put("status", "ERROR");
				map.put("errMsg", arg31.toString());
			}
		}

		response.setContentType("text/plain");
		response.setCharacterEncoding("utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		ObjectMapper arg32 = new ObjectMapper();
		json = arg32.writeValueAsString(map);
		ServletOutputStream arg33 = response.getOutputStream();
		arg33.write(json.getBytes("utf-8"));
		arg33.flush();
		arg33.close();
		return null;
	}

	public ModelAndView handleAppListForUnExam(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HashMap map = new HashMap();
		UserStatus s = EncInterceptorHelper.checkAppUserSignon(request);
		UserBean ub = s.getUserBean();
		String json;
		if (ub == null) {
			map.put("status", "NO_LOGIN");
			map.put("errMsg", "");
		} else if (!EncCommonHelper.checkPrivilege(request, "PAY_UN_EXAM")) {
			map.put("status", "ERROR");
			map.put("errMsg", "您还没有此功能的使用权限，请确认返回！");
		} else {
			try {
				String mapper = request.getParameter("sk");
				json = request.getParameter("ts_id");
				String out = request.getParameter("show_prev");
				String initQuer = request.getParameter("init_quer");
				long mngId = 0L;
				long tsId = 0L;
				if (json != null && !json.equals("")) {
					tsId = Long.parseLong(json);
				}

				if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
					mngId = ub.getStaffer().getId();
				}

				Date allowStart = null;
				if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
					allowStart = EncCommonHelper.getEarlDataDate(request);
				}

				int total = this.payBillDao.getAppListForUnExamCount(mapper,
						tsId, ub, allowStart, mngId);
				int perPageNum = EncCommonHelper.getPageSize(request);
				int pageno = EncCommonHelper.getCurrentPageIndex(request,
						total, perPageNum);
				if (total > pageno * perPageNum) {
					map.put("more", "Y");
				} else {
					map.put("more", "N");
				}

				List list;
				if (out != null && out.equals("Y")) {
					list = this.payBillDao.getAppListForUnExam(mapper, tsId,
							ub, allowStart, mngId, 0, pageno * perPageNum);
				} else {
					list = this.payBillDao.getAppListForUnExam(mapper, tsId,
							ub, allowStart, mngId, (pageno - 1) * perPageNum,
							perPageNum);
				}

				SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
				SimpleDateFormat sfl = new SimpleDateFormat("yyyy-MM-dd HH:mm");
				List baList = this.bankAccountDao.getList("", "");
				ArrayList items = new ArrayList();

				for (int tmpList = 0; tmpList < list.size(); ++tmpList) {
					Object[] tsItems = (Object[]) list.get(tmpList);
					PayBill i = (PayBill) tsItems[0];
					String item = (String) tsItems[1];
					String ts = "";
					String baName = "";
					if (i.getExamineTime() != null) {
						ts = sfl.format(i.getExamineTime());
					}

					if (i.getBankAccountId() != 0L) {
						for (int item1 = 0; item1 < baList.size(); ++item1) {
							BankAccount ba = (BankAccount) baList.get(item1);
							if (ba.getId() == i.getBankAccountId()) {
								baName = ba.getBankName();
								if (ba.getAccountName() != null
										&& !ba.getAccountName().equals("")) {
									baName = baName + "(" + ba.getAccountName()
											+ ")";
								}
								break;
							}
						}
					}

					HashMap arg38 = new HashMap();
					arg38.put("cost", i.getCost());
					arg38.put("examName", i.getExaminerName());
					arg38.put("examTime", ts);
					arg38.put("estName", item);
					arg38.put("id", Long.valueOf(i.getId()));
					arg38.put("date", sf.format(i.getPayDate()));
					arg38.put("baName", baName);
					items.add(arg38);
				}

				map.put("items", items);
				if (initQuer != null && initQuer.equals("Y")) {
					List arg33 = PageHelper.getTallySetList(this.tallySetDao,
							ub);
					ArrayList arg34 = new ArrayList();

					for (int arg35 = 0; arg35 < arg33.size(); ++arg35) {
						HashMap arg36 = new HashMap();
						TallySet arg37 = (TallySet) arg33.get(arg35);
						arg36.put("id", Long.valueOf(arg37.getId()));
						arg36.put("name", arg37.getTitle());
						arg34.add(arg36);
					}

					map.put("tsItems", arg34);
				}

				map.put("status", "OK");
				map.put("errMsg", "");
			} catch (Exception arg30) {
				map.put("status", "ERROR");
				map.put("errMsg", arg30.toString());
			}
		}

		response.setContentType("text/plain");
		response.setCharacterEncoding("utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		ObjectMapper arg31 = new ObjectMapper();
		json = arg31.writeValueAsString(map);
		ServletOutputStream arg32 = response.getOutputStream();
		arg32.write(json.getBytes("utf-8"));
		arg32.flush();
		arg32.close();
		return null;
	}

	public ModelAndView handleAppExam(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		UserStatus s = EncInterceptorHelper.checkAppUserSignon(request);
		UserBean ub = s.getUserBean();
		String status = "";
		String errMsg = "";
		if (ub == null) {
			status = "NO_LOGIN";
		} else {
			String map = request.getParameter("type");
			String mapper = request.getParameter("id");
			if (map != null && map.equals("UNEXAM")) {
				if (!EncCommonHelper.checkPrivilege(request, "PAY_UN_EXAM")) {
					status = "ERROR";
					errMsg = "您还没有此功能的使用权限，请确认返回！";
				} else {
					try {
						this.payBillService.txUnExamine(Long.parseLong(mapper),
								this.payBillDao, this.payBillItemDao,
								this.adjustBillDao, this.bankAccountBalanceDao,
								this.bankAccountDetailDao,
								this.financeDetailDao, this.idGenerator, ub);
						status = "OK";
					} catch (CannotAcquireLockException arg14) {
						status = "ERROR";
						errMsg = "事务冲突故障，请重新操作！";
					} catch (NotAllowException arg15) {
						status = "ERROR";
						errMsg = arg15.getMessage();
					}
				}
			} else if (!EncCommonHelper.checkPrivilege(request, "PAY_EXAM")) {
				status = "ERROR";
				errMsg = "您还没有此功能的使用权限，请确认返回！";
			} else {
				long json = ub.getStaffer().getId();
				String examinerName = ub.getStaffer().getStafferName();

				try {
					this.payBillService.txExamine(Long.parseLong(mapper),
							this.payBillDao, this.payBillItemDao,
							this.adjustBillDao, json, examinerName,
							this.bankAccountBalanceDao, this.idGenerator);
					status = "OK";
				} catch (NotAllowException arg12) {
					status = "ERROR";
					errMsg = arg12.getMessage();
				} catch (CannotAcquireLockException arg13) {
					status = "ERROR";
					errMsg = "事务冲突故障，请重新操作！";
				}
			}
		}

		HashMap map1 = new HashMap();
		map1.put("status", status);
		map1.put("errMsg", errMsg);
		ObjectMapper mapper1 = new ObjectMapper();
		String json1 = mapper1.writeValueAsString(map1);
		ServletOutputStream out = response.getOutputStream();
		out.write(json1.getBytes("utf-8"));
		out.flush();
		out.close();
		return null;
	}

	public ModelAndView handleAppEstUnPay(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HashMap map = new HashMap();
		UserStatus s = EncInterceptorHelper.checkAppUserSignon(request);
		UserBean ub = s.getUserBean();
		String json;
		if (ub == null) {
			map.put("status", "NO_LOGIN");
			map.put("errMsg", "");
		} else if (!EncCommonHelper.checkPrivilege(request, "UN_PAY_SEAR")) {
			map.put("status", "ERROR");
			map.put("errMsg", "您还没有此功能的使用权限，请确认返回！");
		} else {
			try {
				String mapper = request.getParameter("rt");
				json = request.getParameter("est_name");
				String out = request.getParameter("ts_id");
				String initQuer = request.getParameter("init_quer");
				long mngId = 0L;
				long tsId = 0L;
				if (out != null && !out.equals("")) {
					tsId = Long.parseLong(out);
				}

				if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
					mngId = ub.getStaffer().getId();
				}

				Date allowStart = null;
				if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
					allowStart = EncCommonHelper.getEarlDataDate(request);
				}

				int total = 0;
				BigDecimal cost = new BigDecimal(0);
				List list = this.payBillDao.getAppEstUnPayTota(json, mapper,
						tsId, ub, mngId, allowStart);
				if (!list.isEmpty() && list.get(0) != null) {
					Object[] perPageNum = (Object[]) list.get(0);
					if (perPageNum[0] != null) {
						total = Integer.parseInt(perPageNum[0].toString());
					}

					if (perPageNum[1] != null) {
						cost = (BigDecimal) perPageNum[1];
					}
				}

				map.put("cost", cost);
				map.put("total", Integer.valueOf(total));
				int arg30 = EncCommonHelper.getPageSize(request);
				int pageno = EncCommonHelper.getCurrentPageIndex(request,
						total, arg30);
				if (total > pageno * arg30) {
					map.put("more", "Y");
				} else {
					map.put("more", "N");
				}

				SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
				list = this.payBillDao.getAppEstUnPay(json, mapper, tsId, ub,
						mngId, allowStart, (pageno - 1) * arg30, arg30);
				List areaList = this.areaDao.getList(false);
				ArrayList items = new ArrayList();

				for (int tmpList = 0; tmpList < list.size(); ++tmpList) {
					HashMap tsItems = new HashMap();
					Object[] i = (Object[]) list.get(tmpList);
					String item = "";
					if (i[3] != null) {
						item = sf.format((Date) i[3]);
					}

					tsItems.put("estName", i[0]);
					tsItems.put("cost", i[1]);
					tsItems.put("estType", i[2]);
					tsItems.put("busiTime", item);
					tsItems.put("mark", PageHelper.parseNull((String) i[4]));
					tsItems.put("mng", i[5]);
					tsItems.put(
							"area",
							EncCommonHelper.getSimpleObjectName(areaList,
									Long.parseLong(i[6].toString())));
					tsItems.put("estId", i[7]);
					items.add(tsItems);
				}

				map.put("items", items);
				if (initQuer != null && initQuer.equals("Y")) {
					List arg31 = PageHelper.getTallySetList(this.tallySetDao,
							ub);
					ArrayList arg32 = new ArrayList();

					for (int arg33 = 0; arg33 < arg31.size(); ++arg33) {
						HashMap arg34 = new HashMap();
						TallySet ts = (TallySet) arg31.get(arg33);
						arg34.put("id", Long.valueOf(ts.getId()));
						arg34.put("name", ts.getTitle());
						arg32.add(arg34);
					}

					map.put("tsItems", arg32);
				}

				map.put("status", "OK");
				map.put("errMsg", "");
			} catch (Exception arg27) {
				map.put("status", "ERROR");
				map.put("errMsg", arg27.toString());
			}
		}

		response.setContentType("text/plain");
		response.setCharacterEncoding("utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		ObjectMapper arg28 = new ObjectMapper();
		json = arg28.writeValueAsString(map);
		ServletOutputStream arg29 = response.getOutputStream();
		arg29.write(json.getBytes("utf-8"));
		arg29.flush();
		arg29.close();
		return null;
	}

	public ModelAndView handleAppPcList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HashMap map = new HashMap();
		UserStatus s = EncInterceptorHelper.checkAppUserSignon(request);
		UserBean ub = s.getUserBean();
		String estName = request.getParameter("est_name");
		String sDate = request.getParameter("start_date");
		String eDate = request.getParameter("end_date");
		String bt = request.getParameter("bt");
		String tsIdStr = request.getParameter("ts_id");
		String showPrev = request.getParameter("show_prev");
		String type = request.getParameter("type");
		String initQuer = request.getParameter("init_quer");
		String privCode = "COOP_PAY_SEAR";
		String payType = "COOPER";
		if (type.equals("PURC")) {
			privCode = "PURC_PAY_SEAR";
			payType = "PURCHASE";
		}

		if (ub == null) {
			map.put("status", "NO_LOGIN");
			map.put("errMag", "");
		} else if (!EncCommonHelper.checkPrivilege(request, privCode)) {
			map.put("status", "ERROR");
			map.put("errMag", "您还没有此功能的使用权限，请确认返回！");
		} else {
			try {
				long mapper = 0L;
				long out = 0L;
				if (tsIdStr != null && !tsIdStr.equals("")) {
					out = Long.parseLong(tsIdStr);
				}

				if (EncCommonHelper.checkPurePrivilege(request, "BUSI_SELF")) {
					mapper = ub.getStaffer().getId();
				}

				Date allowStart = null;
				Date startDate = null;
				Date endDate = null;
				if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
					allowStart = EncCommonHelper.getEarlDataDate(request);
				}

				SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
				SimpleDateFormat sfl = new SimpleDateFormat("yyyy-MM-dd HH:mm");
				if (sDate != null && !sDate.equals("")) {
					startDate = sf.parse(sDate);
				}

				if (eDate != null && !eDate.equals("")) {
					endDate = sf.parse(EncCommonHelper.getNextDateStr(eDate,
							"yyyy-MM-dd"));
				}

				if (startDate == null) {
					startDate = allowStart;
				} else if (allowStart != null && allowStart.after(startDate)) {
					startDate = allowStart;
				}

				int total = 0;
				BigDecimal cost = new BigDecimal(0);
				List list = this.payBillDao.getAppPcListCount(payType,
						startDate, endDate, estName, bt, out, ub, mapper);
				if (list != null && !list.isEmpty() && list.get(0) != null) {
					Object[] perPageNum = (Object[]) list.get(0);
					if (perPageNum[1] != null) {
						total = Integer.parseInt(perPageNum[0].toString());
						cost = (BigDecimal) perPageNum[1];
					}
				}

				map.put("cost", cost);
				map.put("total", Integer.valueOf(total));
				int arg39 = EncCommonHelper.getPageSize(request);
				int pageno = EncCommonHelper.getCurrentPageIndex(request,
						total, arg39);
				if (total > pageno * arg39) {
					map.put("more", "Y");
				} else {
					map.put("more", "N");
				}

				if (showPrev != null && showPrev.equals("Y")) {
					list = this.payBillDao.getAppPcList(payType, startDate,
							endDate, estName, bt, out, ub, mapper, 0, pageno
									* arg39);
				} else {
					list = this.payBillDao.getAppPcList(payType, startDate,
							endDate, estName, bt, out, ub, mapper, (pageno - 1)
									* arg39, arg39);
				}

				List baList = this.bankAccountDao.getList("", "");
				ArrayList items = new ArrayList();

				for (int tmpList = 0; tmpList < list.size(); ++tmpList) {
					Object[] tsItems = (Object[]) list.get(tmpList);
					String i = (String) tsItems[1];
					String item = "";
					if (tsItems[7] != null) {
						item = sfl.format((Date) tsItems[7]);
					}

					HashMap ts = new HashMap();
					ts.put("id", tsItems[0]);
					ts.put("estName", i);
					ts.put("type", tsItems[2]);
					ts.put("cost", tsItems[3]);
					ts.put("ba",
							EncCommonHelper.getSimpleObjectName(baList,
									Long.parseLong(tsItems[4].toString())));
					ts.put("date", sf.format((Date) tsItems[5]));
					ts.put("creaName", tsItems[6]);
					ts.put("creaTime", item);
					items.add(ts);
				}

				map.put("items", items);
				if (initQuer != null && initQuer.equals("Y")) {
					List arg40 = PageHelper.getTallySetList(this.tallySetDao,
							ub);
					ArrayList arg41 = new ArrayList();

					for (int arg42 = 0; arg42 < arg40.size(); ++arg42) {
						HashMap arg43 = new HashMap();
						TallySet arg44 = (TallySet) arg40.get(arg42);
						arg43.put("id", Long.valueOf(arg44.getId()));
						arg43.put("name", arg44.getTitle());
						arg41.add(arg43);
					}

					map.put("tsItems", arg41);
				}

				map.put("status", "OK");
				map.put("errMsg", "");
			} catch (Exception arg36) {
				map.put("status", "ERROR");
				map.put("errMsg", arg36.toString());
			}
		}

		response.setContentType("text/plain");
		response.setCharacterEncoding("utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		ObjectMapper arg37 = new ObjectMapper();
		String json = arg37.writeValueAsString(map);
		ServletOutputStream arg38 = response.getOutputStream();
		arg38.write(json.getBytes("utf-8"));
		arg38.flush();
		arg38.close();
		return null;
	}

	public ModelAndView handleAppPcInfo(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HashMap map = new HashMap();

		try {
			long mapper = Long.parseLong(request.getParameter("id"));
			String out = request.getParameter("type");
			String billType = request.getParameter("bill_type");
			long baId = 0L;
			long estId = 0L;
			long tsId = 0L;
			String bankName = "";
			String estName = "";
			String date = "";
			String code = "";
			String desc = "";
			String mngName = "";
			String mark = "";
			String creaName = "";
			String creaTime = "";
			String tsName = "";
			new BigDecimal(0);
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
			SimpleDateFormat sfl = new SimpleDateFormat("yyyy-MM-dd HH:mm");
			BigDecimal cost;
			if (out.equals("IMPR")) {
				if (billType.equals("COOP")) {
					CooperBill est = (CooperBill) this.payBillDao.get(
							CooperBill.class, mapper);
					baId = est.getBankAccountId();
					estId = est.getCooperatorId();
					code = est.getBillCode();
					date = sf.format(est.getCooperDate());
					cost = est.getCost();
					mngName = est.getManagerName();
					mark = PageHelper.parseNull(est.getMark());
					desc = PageHelper.parseNull(est.getContent());
					creaName = est.getCreaterName();
					if (est.getCreateTime() != null) {
						creaTime = sfl.format(est.getCreateTime());
					}

					tsId = est.getTallySetId();
				} else {
					PurchaseBill est1 = (PurchaseBill) this.payBillDao.get(
							PurchaseBill.class, mapper);
					baId = est1.getBankAccountId();
					estId = est1.getProviderId();
					code = est1.getBillCode();
					date = sf.format(est1.getPurchaseDate());
					cost = est1.getCost();
					mngName = est1.getManagerName();
					mark = PageHelper.parseNull(est1.getMark());
					desc = PageHelper.parseNull(est1.getContent());
					creaName = est1.getCreaterName();
					if (est1.getCreateTime() != null) {
						creaTime = sfl.format(est1.getCreateTime());
					}

					tsId = est1.getTallySetId();
				}
			} else {
				PayBill est2 = (PayBill) this.payBillDao.get(PayBill.class,
						mapper);
				baId = est2.getBankAccountId();
				estId = est2.getReceiverId();
				code = est2.getBillCode();
				date = sf.format(est2.getPayDate());
				cost = est2.getCost();
				mngName = est2.getManagerName();
				mark = PageHelper.parseNull(est2.getMark());
				desc = PageHelper.parseNull(est2.getDescription());
				creaName = est2.getCreaterName();
				if (est2.getCreateTime() != null) {
					creaTime = sfl.format(est2.getCreateTime());
				}

				tsId = est2.getTallySetId();
			}

			if (baId != 0L) {
				BankAccount est3 = (BankAccount) this.payBillDao.get(
						BankAccount.class, baId);
				if (est3 != null) {
					bankName = est3.getBankName();
				}
			}

			Establishment est4 = (Establishment) this.payBillDao.get(
					Establishment.class, estId);
			if (est4 != null) {
				estName = est4.getEstName();
			}

			TallySet ts = (TallySet) this.payBillDao.get(TallySet.class, tsId);
			if (ts != null) {
				tsName = ts.getTitle();
			}

			map.put("estName", estName);
			map.put("code", code);
			map.put("date", date);
			map.put("desc", desc);
			map.put("cost", cost);
			map.put("ba", bankName);
			map.put("mngName", mngName);
			map.put("mark", mark);
			map.put("creaName", creaName);
			map.put("creaTime", creaTime);
			map.put("tsName", tsName);
			map.put("type", out);
			map.put("status", "OK");
			map.put("errMsg", "");
		} catch (Exception arg28) {
			map.put("status", "ERROR");
			map.put("errMsg", arg28.toString());
		}

		response.setContentType("text/plain");
		response.setCharacterEncoding("utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		ObjectMapper mapper1 = new ObjectMapper();
		String json = mapper1.writeValueAsString(map);
		ServletOutputStream out1 = response.getOutputStream();
		out1.write(json.getBytes("utf-8"));
		out1.flush();
		out1.close();
		return null;
	}

	public String getDialogSuccessView() {
		return this.dialogSuccessView;
	}

	public void setDialogSuccessView(String dialogSuccessView) {
		this.dialogSuccessView = dialogSuccessView;
	}

	public PayBillDao getPayBillDao() {
		return this.payBillDao;
	}

	public void setPayBillDao(PayBillDao payBillDao) {
		this.payBillDao = payBillDao;
	}

	public PayBillItemDao getPayBillItemDao() {
		return this.payBillItemDao;
	}

	public void setPayBillItemDao(PayBillItemDao payBillItemDao) {
		this.payBillItemDao = payBillItemDao;
	}

	public String getInfoForExamineView() {
		return this.infoForExamineView;
	}

	public void setInfoForExamineView(String infoForExamineView) {
		this.infoForExamineView = infoForExamineView;
	}

	public String getInfoForUnExamineView() {
		return this.infoForUnExamineView;
	}

	public void setInfoForUnExamineView(String infoForUnExamineView) {
		this.infoForUnExamineView = infoForUnExamineView;
	}

	public String getListForExamineView() {
		return this.listForExamineView;
	}

	public void setListForExamineView(String listForExamineView) {
		this.listForExamineView = listForExamineView;
	}

	public String getListForUnExamineView() {
		return this.listForUnExamineView;
	}

	public void setListForUnExamineView(String listForUnExamineView) {
		this.listForUnExamineView = listForUnExamineView;
	}

	public String getSearchResultView() {
		return this.searchResultView;
	}

	public void setSearchResultView(String searchResultView) {
		this.searchResultView = searchResultView;
	}

	public DepartmentDao getDepartmentDao() {
		return this.departmentDao;
	}

	public void setDepartmentDao(DepartmentDao departmentDao) {
		this.departmentDao = departmentDao;
	}

	public QueryDao getQueryDao() {
		return this.queryDao;
	}

	public void setQueryDao(QueryDao queryDao) {
		this.queryDao = queryDao;
	}

	public AdjustBillDao getAdjustBillDao() {
		return this.adjustBillDao;
	}

	public void setAdjustBillDao(AdjustBillDao adjustBillDao) {
		this.adjustBillDao = adjustBillDao;
	}

	public String getInfoForCancelView() {
		return this.infoForCancelView;
	}

	public void setInfoForCancelView(String infoForCancelView) {
		this.infoForCancelView = infoForCancelView;
	}

	public String getListForCancelView() {
		return this.listForCancelView;
	}

	public void setListForCancelView(String listForCancelView) {
		this.listForCancelView = listForCancelView;
	}

	public PayBillService getPayBillService() {
		return this.payBillService;
	}

	public void setPayBillService(PayBillService payBillService) {
		this.payBillService = payBillService;
	}

	public DataSource getDataSource() {
		return this.dataSource;
	}

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}

	public BankAccountBalanceDao getBankAccountBalanceDao() {
		return this.bankAccountBalanceDao;
	}

	public void setBankAccountBalanceDao(
			BankAccountBalanceDao bankAccountBalanceDao) {
		this.bankAccountBalanceDao = bankAccountBalanceDao;
	}

	public BankAccountDetailDao getBankAccountDetailDao() {
		return this.bankAccountDetailDao;
	}

	public void setBankAccountDetailDao(
			BankAccountDetailDao bankAccountDetailDao) {
		this.bankAccountDetailDao = bankAccountDetailDao;
	}

	public IdGenerator getIdGenerator() {
		return this.idGenerator;
	}

	public void setIdGenerator(IdGenerator idGenerator) {
		this.idGenerator = idGenerator;
	}

	public PayModeDao getPayModeDao() {
		return this.payModeDao;
	}

	public void setPayModeDao(PayModeDao payModeDao) {
		this.payModeDao = payModeDao;
	}

	public BankAccountDao getBankAccountDao() {
		return this.bankAccountDao;
	}

	public void setBankAccountDao(BankAccountDao bankAccountDao) {
		this.bankAccountDao = bankAccountDao;
	}

	public String getFinanceListForProviderView() {
		return this.financeListForProviderView;
	}

	public void setFinanceListForProviderView(String financeListForProviderView) {
		this.financeListForProviderView = financeListForProviderView;
	}

	public String getItemListForPurchaseBillView() {
		return this.itemListForPurchaseBillView;
	}

	public void setItemListForPurchaseBillView(
			String itemListForPurchaseBillView) {
		this.itemListForPurchaseBillView = itemListForPurchaseBillView;
	}

	public PurchaseBillDao getPurchaseBillDao() {
		return this.purchaseBillDao;
	}

	public void setPurchaseBillDao(PurchaseBillDao purchaseBillDao) {
		this.purchaseBillDao = purchaseBillDao;
	}

	public TallySetDao getTallySetDao() {
		return this.tallySetDao;
	}

	public void setTallySetDao(TallySetDao tallySetDao) {
		this.tallySetDao = tallySetDao;
	}

	public String getPayTypeSelectView() {
		return this.payTypeSelectView;
	}

	public void setPayTypeSelectView(String payTypeSelectView) {
		this.payTypeSelectView = payTypeSelectView;
	}

	public String getPayableListView() {
		return this.payableListView;
	}

	public void setPayableListView(String payableListView) {
		this.payableListView = payableListView;
	}

	public CooperBillDao getCooperBillDao() {
		return this.cooperBillDao;
	}

	public void setCooperBillDao(CooperBillDao cooperBillDao) {
		this.cooperBillDao = cooperBillDao;
	}

	public String getCooPayCostPrintView() {
		return this.cooPayCostPrintView;
	}

	public void setCooPayCostPrintView(String cooPayCostPrintView) {
		this.cooPayCostPrintView = cooPayCostPrintView;
	}

	public String getPurPayCostPrintView() {
		return this.purPayCostPrintView;
	}

	public void setPurPayCostPrintView(String purPayCostPrintView) {
		this.purPayCostPrintView = purPayCostPrintView;
	}

	public String getCooPayCostListView() {
		return this.cooPayCostListView;
	}

	public void setCooPayCostListView(String cooPayCostListView) {
		this.cooPayCostListView = cooPayCostListView;
	}

	public String getPurPayCostListView() {
		return this.purPayCostListView;
	}

	public void setPurPayCostListView(String purPayCostListView) {
		this.purPayCostListView = purPayCostListView;
	}

	public String getItemListForCooperBillView() {
		return this.itemListForCooperBillView;
	}

	public void setItemListForCooperBillView(String itemListForCooperBillView) {
		this.itemListForCooperBillView = itemListForCooperBillView;
	}

	public String getFinanceListForCooperatorView() {
		return this.financeListForCooperatorView;
	}

	public void setFinanceListForCooperatorView(
			String financeListForCooperatorView) {
		this.financeListForCooperatorView = financeListForCooperatorView;
	}

	public String getPrintView() {
		return this.printView;
	}

	public void setPrintView(String printView) {
		this.printView = printView;
	}

	public CodeRuleDao getCodeRuleDao() {
		return this.codeRuleDao;
	}

	public void setCodeRuleDao(CodeRuleDao codeRuleDao) {
		this.codeRuleDao = codeRuleDao;
	}

	public FinanceDetailDao getFinanceDetailDao() {
		return this.financeDetailDao;
	}

	public void setFinanceDetailDao(FinanceDetailDao financeDetailDao) {
		this.financeDetailDao = financeDetailDao;
	}

	public String getPayableCountView() {
		return this.payableCountView;
	}

	public void setPayableCountView(String payableCountView) {
		this.payableCountView = payableCountView;
	}

	public String getListForEstablishmentView() {
		return this.listForEstablishmentView;
	}

	public void setListForEstablishmentView(String listForEstablishmentView) {
		this.listForEstablishmentView = listForEstablishmentView;
	}
}